#pragma once

#include <cstdio>

class WzKeyGenerator
{
public:
	static char* GenerateKeyFromZLZ(char* pathToZLZ)
	{
		FILE* ZLZ = NULL;
		char* key = "tmp";

		{
			ZLZ = fopen(pathToZLZ, "rb");
			if(ZLZ == NULL)
				return NULL;
			else
			{
				key = GenerateWzKey(GetIVFromZLZ(ZLZ), GetAesKeyFromZLZ(ZLZ));
			}
		}

		if(ZLZ != NULL)
		{
			fclose(ZLZ);
		}

		return key;
	}
	static char* GenerateWzKey(char* IV)
	{
		return GenerateWzKey(
	}

private:
	static char* GetIVFromZLZ(FILE* ZLZ)
	{
		char* ret = new char[4];
		fseek(ZLZ, SEEK_SET, 0x10040);
		fread(ret,sizeof(char)+sizeof(ret),4,ZLZ);
		rewind(ZLZ);
	}
	static char* GetAesKeyFromZLZ(FILE* ZLZ)
	{
		char* ret = new char[32];

		fseek(ZLZ, SEEK_SET, 0x10060);
		for(int i = 0; i < 8; i++)
		{
			// offset i*4
			// count 4
			fread((char*)ret[i], sizeof(char)+4, 4, ZLZ);
		}

		return ret;
	}
};